<template>
  <view>
    <view
    @click="goDetil(item.id)"
      class="zhixun"
      v-for="item in getlists"
      :key="item.id"
    >
      <image
        class="image"
        :src="item.img_url"
      ></image>
      <view>
        <view class="title" >
          <text >
            {{item.title}}
          </text>
        </view>
        <view class="time">
          <text>发表时间:{{item.add_time | formData}}</text>
        </view>
        <view class="time">
          <text>浏览次数:{{item.click}}</text>
        </view>
      </view>

    </view>
  </view>
</template>

<script>
export default {
  filters:{
    formData(data){
      const newdata=new Date(data)
      const year=newdata.getFullYear()
      const month=newdata.getMonth()+1
      const dat =newdata.getDay()
      const hour =newdata.getHours()
      const min=newdata.getMinutes()
      return year+'年'+month+'月'+dat+'日'+hour+'时'+min+'分'
    }
  },
  data() {
    return {
      getlists: [],
    };
  },
  onLoad() {
    this.getlist();
  },
  methods: {
    getlist() {
      uni.request({
        url: "http://localhost:8082/api/getnewslist",
        success: (res) => {
          console.log(res.data);
          this.getlists = res.data.message;
        },
      });
    },
    goDetil(id){
      uni.navigateTo({
        url:"/pages/choashi/xxx?id="+id,
        
      })
    }
  },
};
</script>

<style lang="scss" scoped>
.zhixun {
  display: flex;
  margin: 10rpx 0 20rpx 20rpx;
  border-top: 1px solid;
  .image {
    margin-top: 15rpx;
    width: 200rpx;
    height: 200rpx;
  }
  .title {
    margin-top: 15rpx;
    margin-left: 10rpx;
  }
  .time {
    margin: 20rpx 0 20rpx 10rpx;
    font-size: 24rpx;
  }
}
</style>
